package logic

import (
	"context"
	"zy/models/mysql"

	"zy/zyrpc/internal/svc"
	"zy/zyrpc/zyrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginShowLogic {
	return &LoginShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LoginShowLogic) LoginShow(in *zyrpc.LoginShowRequest) (*zyrpc.LoginShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	mysql.DB.Debug().Where("id=?", in.UserId).First(&user)
	return &zyrpc.LoginShowResponse{
		HeadImage: user.HeadImage,
		RealName:  user.RealName,
		UserId:    int64(user.ID),
	}, nil
}
